package oop.ex1.filters;

/**
 * an abstract class that all the permission dependent filter inherits from
 * @author danalmog
 * @author danielshalev
 */
public abstract class PermissionDependent extends Filters {
	protected boolean permit,hasNot;
	
	/**
	 * construct a new filter, checks if the desired permission state is legal and checks if the file stands up in the requirements
	 * @param permission the permission state to check
	 * @param hasNot indicates if the filter is a NOT filter
	 * @throws FilterYesNoExeption indicates that the argument is neither YES nor NO
	 */
	public PermissionDependent(String permission,boolean hasNot) throws FilterYesNoExeption{
		this.hasNot=hasNot;
		if(permission.equals("YES"))
			permit=true;
		else if(permission.equals("NO"))
			permit=false;
		else 
			throw new FilterYesNoExeption();			
		if(hasNot)
			permit=!permit;
	}
	

	
	/**
	 * a getter that returns the desired permission
	 * @return the desired permission
	 */

	public boolean getPermit(){
		return permit;
	}
}
